 /**
 * iBookmark - jQuery plugin 1.0
 *
 * Copyright (c) 20010 Faisal Ahmed
 * http://plugins.jquery.com/project/iBookmark
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 */
 
 (function($){  
  $.fn.ibookmark = function(options) {	 
   var defaults = {
    digg: true,  
    stumbleupon: true,  
    delicious: true,  
    facebook: true,  
    twitter: true,
		bm_title: document.title,
		bm_url: document.location.href
   };
	 
   var options = $.extend(defaults, options);  
       
   return this.each(function(){
		var $this = $(this);		
		var bmtitle = encodeURI(defaults.bm_title);
		var bmurl = encodeURI(defaults.bm_url);
		
		$this.html('');
		
		if(defaults.digg == true){
			var dig_url = 'http://digg.com/submit?phase=2&url=';
			dig_url += encodeURI(bmurl);
			dig_url += '&title='+encodeURI(bmtitle);
			
			$this.append('<a href="'+dig_url+'" title="add to digg"><img src="images/digg-icon.png" border="0" height="38" width="38"/></a>&nbsp;');
		}
		
		if(defaults.stumbleupon == true){
			var stmbl_url = 'http://www.stumbleupon.com/submit?url=';
			stmbl_url += encodeURI(bmurl);
			stmbl_url += '&title='+encodeURI(bmtitle);
			
			$this.append('<a href="'+stmbl_url+'" title="add to stumbleupon"><img src="images/stumbleupon-icon.png" border="0" height="38" width="38"/></a>&nbsp;');
		}
		
		if(defaults.delicious == true){
			var del_url = 'http://delicious.com/post?url=';
			del_url += encodeURI(bmurl);
			del_url += '&title='+decodeURI(bmtitle);
			$this.append('<a href="'+del_url+'" title="add to delicious"><img src="images/delicious-icon.png" border="0" height="38" width="38"/></a>&nbsp;');
		}
		
		if(defaults.facebook == true){
			var fb_url = 'http://www.facebook.com/share.php?v=4&src=bm&u=';
			fb_url += encodeURI(bmurl);
			fb_url += '&t='+encodeURI(bmtitle);
			$this.append('<a href="'+fb_url+'" title="add to facebook"><img src="images/facebook-icon.png" border="0" height="38" width="38"/></a>&nbsp;');
		}
		
		if(defaults.twitter == true){
			var tw_url = 'http://twitter.com/home?status=';
			tw_url += decodeURI(bmtitle+' - '+bmurl);
			tw_url += '&source=ibookmark';
			$this.append('<a href="'+tw_url+'" title="add to twitter"><img src="images/twitter-icon.png" border="0" height="38" width="38"/></a>&nbsp;');
		}
   });  
  };  
 })(jQuery);